home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Programming / SWI / source / man / hack.doc < prev    next >
LaTeX Document  |  1997-01-20  |  8.3 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: LaTeX Document (document/latex).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert MultiMate Document (document/multiMate) ext Unsupported
1% dexvert WANG Integrated Word Processor (document/wangIWP) ext Unsupported
1% dexvert Excellence! Document (document/excellenceDocument) ext Unsupported
1% dexvert IBM DisplayWrite Document (document/ibmDisplayWriteDocument) ext Unsupported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 63 68 61 70 74 65 72 | 7b 48 61 63 6b 65 72 73 |\chapter|{Hackers|
|00000010| 20 63 6f 72 6e 65 72 7d | 0a 0a 54 68 69 73 20 61 | corner}|..This a|
|00000020| 70 70 65 6e 64 69 78 20 | 64 65 73 63 72 69 62 65 |ppendix |describe|
|00000030| 73 20 61 20 6e 75 6d 62 | 65 72 20 6f 66 20 70 72 |s a numb|er of pr|
|00000040| 65 64 69 63 61 74 65 73 | 20 77 68 69 63 68 20 65 |edicates| which e|
|00000050| 6e 61 62 6c 65 20 74 68 | 65 20 50 72 6f 6c 6f 67 |nable th|e Prolog|
|00000060| 0a 75 73 65 72 20 74 6f | 20 69 6e 73 70 65 63 74 |.user to| inspect|
|00000070| 20 74 68 65 20 50 72 6f | 6c 6f 67 20 65 6e 76 69 | the Pro|log envi|
|00000080| 72 6f 6e 6d 65 6e 74 20 | 61 6e 64 20 6d 61 6e 69 |ronment |and mani|
|00000090| 70 75 6c 61 74 65 20 28 | 6f 72 20 65 76 65 6e 20 |pulate (|or even |
|000000a0| 72 65 64 65 66 69 6e 65 | 29 0a 74 68 65 20 64 65 |redefine|).the de|
|000000b0| 62 75 67 67 65 72 2e 20 | 20 54 68 65 79 20 63 61 |bugger. | They ca|
|000000c0| 6e 20 62 65 20 75 73 65 | 64 20 61 73 20 65 6e 74 |n be use|d as ent|
|000000d0| 72 79 20 70 6f 69 6e 74 | 73 20 66 6f 72 20 65 78 |ry point|s for ex|
|000000e0| 70 65 72 69 6d 65 6e 74 | 73 20 77 69 74 68 0a 64 |periment|s with.d|
|000000f0| 65 62 75 67 67 69 6e 67 | 20 74 6f 6f 6c 73 20 66 |ebugging| tools f|
|00000100| 6f 72 20 50 72 6f 6c 6f | 67 2e 20 54 68 65 20 70 |or Prolo|g. The p|
|00000110| 72 65 64 69 63 61 74 65 | 73 20 64 65 73 63 72 69 |redicate|s descri|
|00000120| 62 65 64 20 68 65 72 65 | 20 73 68 6f 75 6c 64 20 |bed here| should |
|00000130| 62 65 0a 68 61 6e 64 6c | 65 64 20 77 69 74 68 20 |be.handl|ed with |
|00000140| 73 6f 6d 65 20 63 61 72 | 65 20 61 73 20 69 74 20 |some car|e as it |
|00000150| 69 73 20 65 61 73 79 20 | 74 6f 20 63 6f 72 72 75 |is easy |to corru|
|00000160| 70 74 20 74 68 65 20 63 | 6f 6e 73 69 73 74 65 6e |pt the c|onsisten|
|00000170| 63 79 20 6f 66 20 74 68 | 65 0a 50 72 6f 6c 6f 67 |cy of th|e.Prolog|
|00000180| 20 73 79 73 74 65 6d 20 | 62 79 20 6d 69 73 75 73 | system |by misus|
|00000190| 69 6e 67 20 74 68 65 6d | 2e 0a 0a 5c 73 65 63 74 |ing them|...\sect|
|000001a0| 69 6f 6e 7b 45 78 61 6d | 69 6e 69 6e 67 20 74 68 |ion{Exam|ining th|
|000001b0| 65 20 45 6e 76 69 72 6f | 6e 6d 65 6e 74 20 53 74 |e Enviro|nment St|
|000001c0| 61 63 6b 7d 0a 0a 5c 62 | 65 67 69 6e 7b 64 65 73 |ack}..\b|egin{des|
|000001d0| 63 72 69 70 74 69 6f 6e | 7d 0a 20 20 20 20 5c 70 |cription|}. \p|
|000001e0| 72 65 64 69 63 61 74 65 | 7b 70 72 6f 6c 6f 67 5f |redicate|{prolog_|
|000001f0| 63 75 72 72 65 6e 74 5f | 66 72 61 6d 65 7d 7b 31 |current_|frame}{1|
|00000200| 7d 7b 2d 46 72 61 6d 65 | 7d 0a 55 6e 69 66 79 20 |}{-Frame|}.Unify |
|00000210| 5c 61 72 67 7b 46 72 61 | 6d 65 7d 20 77 69 74 68 |\arg{Fra|me} with|
|00000220| 20 61 6e 20 69 6e 74 65 | 67 65 72 20 70 72 6f 76 | an inte|ger prov|
|00000230| 69 64 69 6e 67 20 61 20 | 72 65 66 65 72 65 6e 63 |iding a |referenc|
|00000240| 65 20 74 6f 20 74 68 65 | 20 70 61 72 65 6e 74 20 |e to the| parent |
|00000250| 6f 66 0a 74 68 65 20 63 | 75 72 72 65 6e 74 20 6c |of.the c|urrent l|
|00000260| 6f 63 61 6c 20 73 74 61 | 63 6b 20 66 72 61 6d 65 |ocal sta|ck frame|
|00000270| 2e 20 20 41 20 70 6f 69 | 6e 74 65 72 20 74 6f 20 |. A poi|nter to |
|00000280| 74 68 65 20 63 75 72 72 | 65 6e 74 20 6c 6f 63 61 |the curr|ent loca|
|00000290| 6c 20 66 72 61 6d 65 0a | 63 61 6e 6e 6f 74 20 62 |l frame.|cannot b|
|000002a0| 65 20 70 72 6f 76 69 64 | 65 64 20 61 73 20 74 68 |e provid|ed as th|
|000002b0| 65 20 70 72 65 64 69 63 | 61 74 65 20 73 75 63 63 |e predic|ate succ|
|000002c0| 65 65 64 73 20 64 65 74 | 65 72 6d 69 6e 69 73 74 |eeds det|erminist|
|000002d0| 69 63 61 6c 6c 79 20 61 | 6e 64 0a 74 68 65 72 65 |ically a|nd.there|
|000002e0| 66 6f 72 65 20 69 74 73 | 20 66 72 61 6d 65 20 69 |fore its| frame i|
|000002f0| 73 20 64 65 73 74 72 6f | 79 65 64 20 69 6d 6d 65 |s destro|yed imme|
|00000300| 64 69 61 74 65 6c 79 20 | 61 66 74 65 72 20 73 75 |diately |after su|
|00000310| 63 63 65 65 64 69 6e 67 | 2e 0a 0a 20 20 20 20 5c |cceeding|... \|
|00000320| 70 72 65 64 69 63 61 74 | 65 7b 70 72 6f 6c 6f 67 |predicat|e{prolog|
|00000330| 5f 66 72 61 6d 65 5f 61 | 74 74 72 69 62 75 74 65 |_frame_a|ttribute|
|00000340| 7d 7b 33 7d 7b 2b 46 72 | 61 6d 65 2c 20 2b 4b 65 |}{3}{+Fr|ame, +Ke|
|00000350| 79 2c 20 2d 56 61 6c 75 | 65 7d 0a 4f 62 74 61 69 |y, -Valu|e}.Obtai|
|00000360| 6e 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 61 62 |n inform|ation ab|
|00000370| 6f 75 74 20 74 68 65 20 | 6c 6f 63 61 6c 20 73 74 |out the |local st|
|00000380| 61 63 6b 20 66 72 61 6d | 65 20 5c 61 72 67 7b 46 |ack fram|e \arg{F|
|00000390| 72 61 6d 65 7d 2e 20 20 | 5c 61 72 67 7b 46 72 61 |rame}. |\arg{Fra|
|000003a0| 6d 65 7d 0a 69 73 20 61 | 20 66 72 61 6d 65 20 72 |me}.is a| frame r|
|000003b0| 65 66 65 72 65 6e 63 65 | 20 61 73 20 6f 62 74 61 |eference| as obta|
|000003c0| 69 6e 65 64 20 74 68 72 | 6f 75 67 68 20 70 72 6f |ined thr|ough pro|
|000003d0| 6c 6f 67 5f 63 75 72 72 | 65 6e 74 5f 66 72 61 6d |log_curr|ent_fram|
|000003e0| 65 2f 31 2c 20 0a 70 72 | 6f 6c 6f 67 5f 74 72 61 |e/1, .pr|olog_tra|
|000003f0| 63 65 5f 69 6e 74 65 72 | 63 65 70 74 69 6f 6e 2f |ce_inter|ception/|
|00000400| 34 20 6f 72 20 74 68 69 | 73 20 70 72 65 64 69 63 |4 or thi|s predic|
|00000410| 61 74 65 2e 20 20 54 68 | 65 20 6b 65 79 20 76 61 |ate. Th|e key va|
|00000420| 6c 75 65 73 20 61 72 65 | 0a 64 65 73 63 72 69 62 |lues are|.describ|
|00000430| 65 64 20 62 65 6c 6f 77 | 2e 0a 0a 5c 62 65 67 69 |ed below|...\begi|
|00000440| 6e 7b 64 65 73 63 72 69 | 70 74 69 6f 6e 7d 0a 20 |n{descri|ption}. |
|00000450| 20 20 20 5c 74 65 72 6d | 69 74 65 6d 7b 61 6c 74 | \term|item{alt|
|00000460| 65 72 6e 61 74 69 76 65 | 7d 7b 7d 0a 5c 61 72 67 |ernative|}{}.\arg|
|00000470| 7b 56 61 6c 75 65 7d 20 | 69 73 20 75 6e 69 66 69 |{Value} |is unifi|
|00000480| 65 64 20 77 69 74 68 20 | 61 6e 20 69 6e 74 65 67 |ed with |an integ|
|00000490| 65 72 20 72 65 66 65 72 | 65 6e 63 65 20 74 6f 20 |er refer|ence to |
|000004a0| 74 68 65 20 6c 6f 63 61 | 6c 20 73 74 61 63 6b 0a |the loca|l stack.|
|000004b0| 66 72 61 6d 65 20 69 6e | 20 77 68 69 63 68 20 65 |frame in| which e|
|000004c0| 78 65 63 75 74 69 6f 6e | 20 69 73 20 72 65 73 75 |xecution| is resu|
|000004d0| 6d 65 64 20 69 66 20 74 | 68 65 20 67 6f 61 6c 20 |med if t|he goal |
|000004e0| 61 73 73 6f 63 69 61 74 | 65 64 20 77 69 74 68 0a |associat|ed with.|
|000004f0| 5c 61 72 67 7b 46 72 61 | 6d 65 7d 20 66 61 69 6c |\arg{Fra|me} fail|
|00000500| 73 2e 20 46 61 69 6c 73 | 20 69 66 20 74 68 65 20 |s. Fails| if the |
|00000510| 66 72 61 6d 65 20 68 61 | 73 20 6e 6f 20 61 6c 74 |frame ha|s no alt|
|00000520| 65 72 6e 61 74 69 76 65 | 20 66 72 61 6d 65 2e 0a |ernative| frame..|
|00000530| 20 20 20 20 5c 74 65 72 | 6d 69 74 65 6d 7b 68 61 | \ter|mitem{ha|
|00000540| 73 5f 61 6c 74 65 72 6e | 61 74 69 76 65 73 7d 7b |s_altern|atives}{|
|00000550| 7d 0a 5c 61 72 67 7b 56 | 61 6c 75 65 7d 20 69 73 |}.\arg{V|alue} is|
|00000560| 20 75 6e 69 66 69 65 64 | 20 77 69 74 68 20 5c 63 | unified| with \c|
|00000570| 6f 6e 73 74 7b 74 72 75 | 65 7d 20 69 66 20 5c 61 |onst{tru|e} if \a|
|00000580| 72 67 7b 46 72 61 6d 65 | 7d 20 73 74 69 6c 6c 20 |rg{Frame|} still |
|00000590| 69 73 20 61 0a 63 61 6e | 64 69 64 61 74 65 20 66 |is a.can|didate f|
|000005a0| 6f 72 20 62 61 63 6b 74 | 72 61 63 6b 69 6e 67 2e |or backt|racking.|
|000005b0| 20 5c 63 6f 6e 73 74 7b | 66 61 6c 73 65 7d 20 6f | \const{|false} o|
|000005c0| 74 68 65 72 77 69 73 65 | 2e 0a 20 20 20 20 5c 74 |therwise|.. \t|
|000005d0| 65 72 6d 69 74 65 6d 7b | 67 6f 61 6c 7d 7b 7d 0a |ermitem{|goal}{}.|
|000005e0| 5c 61 72 67 7b 56 61 6c | 75 65 7d 20 69 73 20 75 |\arg{Val|ue} is u|
|000005f0| 6e 69 66 69 65 64 20 77 | 69 74 68 20 74 68 65 20 |nified w|ith the |
|00000600| 67 6f 61 6c 20 61 73 73 | 6f 63 69 61 74 65 64 20 |goal ass|ociated |
|00000610| 77 69 74 68 20 5c 61 72 | 67 7b 46 72 61 6d 65 7d |with \ar|g{Frame}|
|00000620| 2e 20 49 66 20 74 68 65 | 0a 64 65 66 69 6e 69 74 |. If the|.definit|
|00000630| 69 6f 6e 20 6d 6f 64 75 | 6c 65 20 6f 66 20 74 68 |ion modu|le of th|
|00000640| 65 20 61 63 74 69 76 65 | 20 70 72 65 64 69 63 61 |e active| predica|
|00000650| 74 65 20 69 73 20 6e 6f | 74 20 5c 63 6f 6e 73 74 |te is no|t \const|
|00000660| 7b 75 73 65 72 7d 20 74 | 68 65 20 67 6f 61 6c 0a |{user} t|he goal.|
|00000670| 69 73 20 72 65 70 72 65 | 73 65 6e 74 65 64 20 61 |is repre|sented a|
|00000680| 73 20 5c 6d 62 6f 78 7b | 5c 74 74 20 3c 6d 6f 64 |s \mbox{|\tt <mod|
|00000690| 75 6c 65 3e 3a 3c 67 6f | 61 6c 3e 7d 2e 20 44 6f |ule>:<go|al>}. Do|
|000006a0| 20 6e 6f 74 20 69 6e 73 | 74 61 6e 74 69 61 74 65 | not ins|tantiate|
|000006b0| 0a 76 61 72 69 61 62 6c | 65 73 20 69 6e 20 74 68 |.variabl|es in th|
|000006c0| 69 73 20 67 6f 61 6c 20 | 75 6e 6c 65 73 73 20 79 |is goal |unless y|
|000006d0| 6f 75 20 7b 5c 62 66 20 | 6b 6e 6f 77 7d 20 77 68 |ou {\bf |know} wh|
|000006e0| 61 74 20 79 6f 75 20 61 | 72 65 20 64 6f 69 6e 67 |at you a|re doing|
|000006f0| 21 0a 20 20 20 20 5c 74 | 65 72 6d 69 74 65 6d 7b |!. \t|ermitem{|
|00000700| 63 6c 61 75 73 65 7d 7b | 7d 0a 5c 61 72 67 7b 56 |clause}{|}.\arg{V|
|00000710| 61 6c 75 65 7d 20 69 73 | 20 75 6e 69 66 69 65 64 |alue} is| unified|
|00000720| 20 77 69 74 68 20 61 20 | 72 65 66 65 72 65 6e 63 | with a |referenc|
|00000730| 65 20 74 6f 20 74 68 65 | 20 63 75 72 72 65 6e 74 |e to the| current|
|00000740| 6c 79 20 72 75 6e 6e 69 | 6e 67 20 63 6c 61 75 73 |ly runni|ng claus|
|00000750| 65 2e 0a 46 61 69 6c 73 | 20 69 66 20 74 68 65 20 |e..Fails| if the |
|00000760| 63 75 72 72 65 6e 74 20 | 67 6f 61 6c 20 69 73 20 |current |goal is |
|00000770| 61 73 73 6f 63 69 61 74 | 65 64 20 77 69 74 68 20 |associat|ed with |
|00000780| 61 20 66 6f 72 65 69 67 | 6e 20 28 43 29 20 64 65 |a foreig|n (C) de|
|00000790| 66 69 6e 65 64 0a 70 72 | 65 64 69 63 61 74 65 2e |fined.pr|edicate.|
|000007a0| 20 53 65 65 20 61 6c 73 | 6f 20 6e 74 68 5f 63 6c | See als|o nth_cl|
|000007b0| 61 75 73 65 2f 33 20 61 | 6e 64 20 63 6c 61 75 73 |ause/3 a|nd claus|
|000007c0| 65 5f 70 72 6f 70 65 72 | 74 79 2f 32 2e 0a 20 20 |e_proper|ty/2.. |
|000007d0| 20 20 5c 74 65 72 6d 69 | 74 65 6d 7b 6c 65 76 65 | \termi|tem{leve|
|000007e0| 6c 7d 7b 7d 0a 5c 61 72 | 67 7b 56 61 6c 75 65 7d |l}{}.\ar|g{Value}|
|000007f0| 20 69 73 20 75 6e 69 66 | 69 65 64 20 77 69 74 68 | is unif|ied with|
|00000800| 20 74 68 65 20 72 65 63 | 75 72 73 69 6f 6e 20 6c | the rec|ursion l|
|00000810| 65 76 65 6c 20 6f 66 20 | 5c 61 72 67 7b 46 72 61 |evel of |\arg{Fra|
|00000820| 6d 65 7d 2e 20 54 68 65 | 20 74 6f 70 0a 6c 65 76 |me}. The| top.lev|
|00000830| 65 6c 20 66 72 61 6d 65 | 20 69 73 20 61 74 20 6c |el frame| is at l|
|00000840| 65 76 65 6c 20 60 30 27 | 2e 0a 20 20 20 20 5c 74 |evel `0'|.. \t|
|00000850| 65 72 6d 69 74 65 6d 7b | 70 61 72 65 6e 74 7d 7b |ermitem{|parent}{|
|00000860| 7d 0a 5c 61 72 67 7b 56 | 61 6c 75 65 7d 20 69 73 |}.\arg{V|alue} is|
|00000870| 20 75 6e 69 66 69 65 64 | 20 77 69 74 68 20 61 6e | unified| with an|
|00000880| 20 69 6e 74 65 67 65 72 | 20 72 65 66 65 72 65 6e | integer| referen|
|00000890| 63 65 20 74 6f 20 74 68 | 65 20 70 61 72 65 6e 74 |ce to th|e parent|
|000008a0| 20 6c 6f 63 61 6c 0a 73 | 74 61 63 6b 20 66 72 61 | local.s|tack fra|
|000008b0| 6d 65 20 6f 66 20 5c 61 | 72 67 7b 46 72 61 6d 65 |me of \a|rg{Frame|
|000008c0| 7d 2e 20 46 61 69 6c 73 | 20 69 66 20 5c 61 72 67 |}. Fails| if \arg|
|000008d0| 7b 46 72 61 6d 65 7d 20 | 69 73 20 74 68 65 20 74 |{Frame} |is the t|
|000008e0| 6f 70 20 66 72 61 6d 65 | 2e 0a 20 20 20 20 5c 74 |op frame|.. \t|
|000008f0| 65 72 6d 69 74 65 6d 7b | 63 6f 6e 74 65 78 74 5f |ermitem{|context_|
|00000900| 6d 6f 64 75 6c 65 7d 7b | 7d 0a 5c 61 72 67 7b 56 |module}{|}.\arg{V|
|00000910| 61 6c 75 65 7d 20 69 73 | 20 75 6e 69 66 69 65 64 |alue} is| unified|
|00000920| 20 77 69 74 68 20 74 68 | 65 20 6e 61 6d 65 20 6f | with th|e name o|
|00000930| 66 20 74 68 65 20 63 6f | 6e 74 65 78 74 20 6d 6f |f the co|ntext mo|
|00000940| 64 75 6c 65 20 6f 66 20 | 74 68 65 0a 65 6e 76 69 |dule of |the.envi|
|00000950| 72 6f 6e 6d 65 6e 74 2e | 0a 20 20 20 20 5c 74 65 |ronment.|. \te|
|00000960| 72 6d 69 74 65 6d 7b 74 | 6f 70 7d 7b 7d 0a 5c 61 |rmitem{t|op}{}.\a|
|00000970| 72 67 7b 56 61 6c 75 65 | 7d 20 69 73 20 75 6e 69 |rg{Value|} is uni|
|00000980| 66 69 65 64 20 77 69 74 | 68 20 5c 63 6f 6e 73 74 |fied wit|h \const|
|00000990| 7b 74 72 75 65 7d 20 69 | 66 20 5c 61 72 67 7b 46 |{true} i|f \arg{F|
|000009a0| 72 61 6d 65 7d 20 69 73 | 20 74 68 65 20 74 6f 70 |rame} is| the top|
|000009b0| 20 50 72 6f 6c 6f 67 0a | 67 6f 61 6c 20 66 72 6f | Prolog.|goal fro|
|000009c0| 6d 20 61 20 72 65 63 75 | 72 73 69 76 65 20 63 61 |m a recu|rsive ca|
|000009d0| 6c 6c 20 62 61 63 6b 20 | 66 72 6f 6d 20 74 68 65 |ll back |from the|
|000009e0| 20 66 6f 72 65 69 67 6e | 20 6c 61 6e 67 75 61 67 | foreign| languag|
|000009f0| 65 2e 20 5c 63 6f 6e 73 | 74 7b 66 61 6c 73 65 7d |e. \cons|t{false}|
|00000a00| 0a 6f 74 68 65 72 77 69 | 73 65 2e 0a 20 20 20 20 |.otherwi|se.. |
|00000a10| 5c 74 65 72 6d 69 74 65 | 6d 7b 68 69 64 64 65 6e |\termite|m{hidden|
|00000a20| 7d 7b 7d 0a 5c 61 72 67 | 7b 56 61 6c 75 65 7d 20 |}{}.\arg|{Value} |
|00000a30| 69 73 20 75 6e 69 66 69 | 65 64 20 77 69 74 68 20 |is unifi|ed with |
|00000a40| 5c 63 6f 6e 73 74 7b 74 | 72 75 65 7d 20 69 66 20 |\const{t|rue} if |
|00000a50| 74 68 65 20 66 72 61 6d | 65 20 69 73 20 68 69 64 |the fram|e is hid|
|00000a60| 64 65 6e 20 66 72 6f 6d | 20 74 68 65 0a 75 73 65 |den from| the.use|
|00000a70| 72 2c 20 65 69 74 68 65 | 72 20 62 65 63 61 75 73 |r, eithe|r becaus|
|00000a80| 65 20 61 20 70 61 72 65 | 6e 74 20 68 61 73 20 74 |e a pare|nt has t|
|00000a90| 68 65 20 68 69 64 65 2d | 63 68 69 6c 64 73 20 61 |he hide-|childs a|
|00000aa0| 74 74 72 69 62 75 74 65 | 20 28 61 6c 6c 20 73 79 |ttribute| (all sy|
|00000ab0| 73 74 65 6d 0a 70 72 65 | 64 69 63 61 74 65 73 29 |stem.pre|dicates)|
|00000ac0| 2c 20 6f 72 20 74 68 65 | 20 73 79 73 74 65 6d 20 |, or the| system |
|00000ad0| 68 61 73 20 6e 6f 20 74 | 72 61 63 65 2d 6d 65 20 |has no t|race-me |
|00000ae0| 61 74 74 72 69 62 75 74 | 65 2e 0a 20 20 20 20 5c |attribut|e.. \|
|00000af0| 74 65 72 6d 69 74 65 6d | 7b 70 63 7d 7b 7d 0a 5c |termitem|{pc}{}.\|
|00000b00| 61 72 67 7b 56 61 6c 75 | 65 7d 20 69 73 20 75 6e |arg{Valu|e} is un|
|00000b10| 69 66 69 65 64 20 77 69 | 74 68 20 74 68 65 20 70 |ified wi|th the p|
|00000b20| 72 6f 67 72 61 6d 2d 70 | 6f 69 6e 74 65 72 20 73 |rogram-p|ointer s|
|00000b30| 61 76 65 64 20 6f 6e 20 | 62 65 68 61 6c 76 65 20 |aved on |behalve |
|00000b40| 6f 66 20 74 68 65 0a 70 | 61 72 65 6e 74 2d 67 6f |of the.p|arent-go|
|00000b50| 61 6c 20 69 66 20 74 68 | 65 20 70 61 72 65 6e 74 |al if th|e parent|
|00000b60| 2d 67 6f 61 6c 20 69 73 | 20 6e 6f 74 20 6f 77 6e |-goal is| not own|
|00000b70| 65 64 20 62 79 20 61 20 | 66 6f 72 65 69 67 6e 20 |ed by a |foreign |
|00000b80| 70 72 65 64 69 63 61 74 | 65 2e 0a 20 20 20 20 5c |predicat|e.. \|
|00000b90| 74 65 72 6d 69 74 65 6d | 7b 61 72 67 75 6d 65 6e |termitem|{argumen|
|00000ba0| 74 7d 7b 4e 7d 0a 5c 61 | 72 67 7b 56 61 6c 75 65 |t}{N}.\a|rg{Value|
|00000bb0| 7d 20 69 73 20 75 6e 69 | 66 69 65 64 20 77 69 74 |} is uni|fied wit|
|00000bc0| 68 20 74 68 65 20 5c 61 | 72 67 7b 4e 7d 2d 74 68 |h the \a|rg{N}-th|
|00000bd0| 20 73 6c 6f 74 20 6f 66 | 20 74 68 65 20 66 72 61 | slot of| the fra|
|00000be0| 6d 65 2e 20 41 72 67 75 | 6d 65 6e 74 0a 31 20 69 |me. Argu|ment.1 i|
|00000bf0| 73 20 74 68 65 20 66 69 | 72 73 74 20 61 72 67 75 |s the fi|rst argu|
|00000c00| 6d 65 6e 74 20 6f 66 20 | 74 68 65 20 67 6f 61 6c |ment of |the goal|
|00000c10| 2e 20 41 72 67 75 6d 65 | 6e 74 73 20 61 62 6f 76 |. Argume|nts abov|
|00000c20| 65 20 74 68 65 20 61 72 | 69 74 79 0a 72 65 66 65 |e the ar|ity.refe|
|00000c30| 72 20 74 6f 20 6c 6f 63 | 61 6c 20 76 61 72 69 61 |r to loc|al varia|
|00000c40| 62 6c 65 73 2e 20 46 61 | 69 6c 73 20 73 69 6c 65 |bles. Fa|ils sile|
|00000c50| 6e 74 6c 79 20 69 66 20 | 5c 61 72 67 7b 4e 7d 20 |ntly if |\arg{N} |
|00000c60| 69 73 20 6f 75 74 20 6f | 66 20 72 61 6e 67 65 2e |is out o|f range.|
|00000c70| 0a 5c 65 6e 64 7b 64 65 | 73 63 72 69 70 74 69 6f |.\end{de|scriptio|
|00000c80| 6e 7d 0a 5c 65 6e 64 7b | 64 65 73 63 72 69 70 74 |n}.\end{|descript|
|00000c90| 69 6f 6e 7d 0a 0a 0a 5c | 73 65 63 74 69 6f 6e 7b |ion}...\|section{|
|00000ca0| 49 6e 74 65 72 63 65 70 | 74 69 6e 67 20 74 68 65 |Intercep|ting the|
|00000cb0| 20 54 72 61 63 65 72 7d | 0a 0a 5c 62 65 67 69 6e | Tracer}|..\begin|
|00000cc0| 7b 64 65 73 63 72 69 70 | 74 69 6f 6e 7d 0a 20 20 |{descrip|tion}. |
|00000cd0| 20 20 5c 70 72 65 64 69 | 63 61 74 65 7b 70 72 6f | \predi|cate{pro|
|00000ce0| 6c 6f 67 5f 74 72 61 63 | 65 5f 69 6e 74 65 72 63 |log_trac|e_interc|
|00000cf0| 65 70 74 69 6f 6e 7d 7b | 34 7d 7b 2b 50 6f 72 74 |eption}{|4}{+Port|
|00000d00| 2c 20 2b 46 72 61 6d 65 | 2c 20 2b 50 43 2c 20 2d |, +Frame|, +PC, -|
|00000d10| 41 63 74 69 6f 6e 7d 0a | 44 79 6e 61 6d 69 63 20 |Action}.|Dynamic |
|00000d20| 70 72 65 64 69 63 61 74 | 65 2c 20 6e 6f 72 6d 61 |predicat|e, norma|
|00000d30| 6c 6c 79 20 6e 6f 74 20 | 64 65 66 69 6e 65 64 2e |lly not |defined.|
|00000d40| 20 54 68 69 73 20 70 72 | 65 64 69 63 61 74 65 20 | This pr|edicate |
|00000d50| 69 73 20 63 61 6c 6c 65 | 64 20 66 72 6f 6d 0a 74 |is calle|d from.t|
|00000d60| 68 65 20 53 57 49 2d 50 | 72 6f 6c 6f 67 20 64 65 |he SWI-P|rolog de|
|00000d70| 62 75 67 67 65 72 20 6a | 75 73 74 20 62 65 66 6f |bugger j|ust befo|
|00000d80| 72 65 20 69 74 20 77 6f | 75 6c 64 20 73 68 6f 77 |re it wo|uld show|
|00000d90| 20 61 20 70 6f 72 74 2e | 20 49 66 20 74 68 69 73 | a port.| If this|
|00000da0| 0a 70 72 65 64 69 63 61 | 74 65 20 73 75 63 63 65 |.predica|te succe|
|00000db0| 65 64 73 20 74 68 65 20 | 64 65 62 75 67 67 65 72 |eds the |debugger|
|00000dc0| 20 61 73 73 75 6d 65 73 | 20 74 68 65 20 74 72 61 | assumes| the tra|
|00000dd0| 63 65 20 61 63 74 69 6f | 6e 20 68 61 73 20 62 65 |ce actio|n has be|
|00000de0| 65 6e 20 74 61 6b 65 6e | 0a 63 61 72 65 20 6f 66 |en taken|.care of|
|00000df0| 20 61 6e 64 20 63 6f 6e | 74 69 6e 75 65 73 20 65 | and con|tinues e|
|00000e00| 78 65 63 75 74 69 6f 6e | 20 61 73 20 64 65 73 63 |xecution| as desc|
|00000e10| 72 69 62 65 64 20 62 79 | 20 5c 61 72 67 7b 41 63 |ribed by| \arg{Ac|
|00000e20| 74 69 6f 6e 7d 2e 20 4f | 74 68 65 72 77 69 73 65 |tion}. O|therwise|
|00000e30| 0a 74 68 65 20 6e 6f 72 | 6d 61 6c 20 50 72 6f 6c |.the nor|mal Prol|
|00000e40| 6f 67 20 64 65 62 75 67 | 67 65 72 20 61 63 74 69 |og debug|ger acti|
|00000e50| 6f 6e 73 20 61 72 65 20 | 70 65 72 66 6f 72 6d 65 |ons are |performe|
|00000e60| 64 2e 0a 0a 5c 61 72 67 | 7b 50 6f 72 74 7d 20 69 |d...\arg|{Port} i|
|00000e70| 73 20 6f 6e 65 20 6f 66 | 20 5c 63 6f 6e 73 74 7b |s one of| \const{|
|00000e80| 63 61 6c 6c 7d 2c 20 5c | 63 6f 6e 73 74 7b 72 65 |call}, \|const{re|
|00000e90| 64 6f 7d 2c 20 5c 63 6f | 6e 73 74 7b 65 78 69 74 |do}, \co|nst{exit|
|00000ea0| 7d 2c 20 5c 63 6f 6e 73 | 74 7b 66 61 69 6c 7d 20 |}, \cons|t{fail} |
|00000eb0| 6f 72 0a 5c 63 6f 6e 73 | 74 7b 75 6e 69 66 79 7d |or.\cons|t{unify}|
|00000ec0| 2e 20 5c 61 72 67 7b 46 | 72 61 6d 65 7d 20 69 73 |. \arg{F|rame} is|
|00000ed0| 20 61 6e 20 69 6e 74 65 | 67 65 72 20 72 65 66 65 | an inte|ger refe|
|00000ee0| 72 65 6e 63 65 20 74 6f | 20 74 68 65 20 63 75 72 |rence to| the cur|
|00000ef0| 72 65 6e 74 20 6c 6f 63 | 61 6c 0a 73 74 61 63 6b |rent loc|al.stack|
|00000f00| 20 66 72 61 6d 65 2e 20 | 5c 61 72 67 7b 50 43 7d | frame. |\arg{PC}|
|00000f10| 20 69 73 20 74 68 65 20 | 63 75 72 72 65 6e 74 20 | is the |current |
|00000f20| 76 61 6c 75 65 20 6f 66 | 20 74 68 65 20 70 72 6f |value of| the pro|
|00000f30| 67 72 61 6d 2d 63 6f 75 | 6e 74 65 72 2c 0a 72 65 |gram-cou|nter,.re|
|00000f40| 6c 61 74 69 76 65 20 74 | 6f 20 74 68 65 20 73 74 |lative t|o the st|
|00000f50| 61 72 74 20 6f 66 20 74 | 68 65 20 63 75 72 72 65 |art of t|he curre|
|00000f60| 6e 74 20 63 6c 61 75 73 | 65 2c 20 6f 72 20 30 20 |nt claus|e, or 0 |
|00000f70| 69 66 20 69 74 20 69 73 | 20 69 6e 76 61 6c 69 64 |if it is| invalid|
|00000f80| 2c 0a 66 6f 72 20 65 78 | 61 6d 70 6c 65 20 62 65 |,.for ex|ample be|
|00000f90| 63 61 75 73 65 20 74 68 | 65 20 63 75 72 72 65 6e |cause th|e curren|
|00000fa0| 74 20 66 72 61 6d 65 20 | 72 75 6e 73 20 61 20 66 |t frame |runs a f|
|00000fb0| 6f 72 65 69 67 6e 20 70 | 72 65 64 69 63 61 74 65 |oreign p|redicate|
|00000fc0| 2c 20 6f 72 0a 6e 6f 20 | 63 6c 61 75 73 65 20 68 |, or.no |clause h|
|00000fd0| 61 73 20 62 65 65 6e 20 | 73 65 6c 65 63 74 65 64 |as been |selected|
|00000fe0| 20 79 65 74 2e 20 5c 61 | 72 67 7b 41 63 74 69 6f | yet. \a|rg{Actio|
|00000ff0| 6e 7d 20 73 68 6f 75 6c | 64 20 62 65 20 75 6e 69 |n} shoul|d be uni|
|00001000| 66 69 65 64 20 77 69 74 | 68 20 6f 6e 65 0a 6f 66 |fied wit|h one.of|
|00001010| 20 74 68 65 20 61 74 6f | 6d 73 20 5c 63 6f 6e 73 | the ato|ms \cons|
|00001020| 74 7b 63 6f 6e 74 69 6e | 75 65 7d 20 28 6a 75 73 |t{contin|ue} (jus|
|00001030| 74 20 63 6f 6e 74 69 6e | 75 65 20 65 78 65 63 75 |t contin|ue execu|
|00001040| 74 69 6f 6e 29 2c 20 5c | 63 6f 6e 73 74 7b 72 65 |tion), \|const{re|
|00001050| 74 72 79 7d 0a 28 72 65 | 74 72 79 20 74 68 65 20 |try}.(re|try the |
|00001060| 63 75 72 72 65 6e 74 20 | 67 6f 61 6c 29 20 6f 72 |current |goal) or|
|00001070| 20 5c 63 6f 6e 73 74 7b | 66 61 69 6c 7d 20 28 66 | \const{|fail} (f|
|00001080| 6f 72 63 65 20 74 68 65 | 20 63 75 72 72 65 6e 74 |orce the| current|
|00001090| 20 67 6f 61 6c 20 74 6f | 20 66 61 69 6c 29 2e 0a | goal to| fail)..|
|000010a0| 4c 65 61 76 69 6e 67 20 | 69 74 20 61 20 76 61 72 |Leaving |it a var|
|000010b0| 69 61 62 6c 65 20 69 73 | 20 69 64 65 6e 74 69 63 |iable is| identic|
|000010c0| 61 6c 20 74 6f 20 5c 63 | 6f 6e 73 74 7b 63 6f 6e |al to \c|onst{con|
|000010d0| 74 69 6e 75 65 7d 2e 0a | 0a 54 6f 67 65 74 68 65 |tinue}..|.Togethe|
|000010e0| 72 20 77 69 74 68 20 74 | 68 65 20 70 72 65 64 69 |r with t|he predi|
|000010f0| 63 61 74 65 73 20 64 65 | 73 63 72 69 62 65 64 20 |cates de|scribed |
|00001100| 69 6e 20 5c 73 65 63 72 | 65 66 7b 64 65 62 75 67 |in \secr|ef{debug|
|00001110| 67 65 72 7d 0a 61 6e 64 | 20 74 68 65 20 6f 74 68 |ger}.and| the oth|
|00001120| 65 72 20 70 72 65 64 69 | 63 61 74 65 73 20 6f 66 |er predi|cates of|
|00001130| 20 74 68 69 73 20 63 68 | 61 70 74 65 72 20 74 68 | this ch|apter th|
|00001140| 69 73 20 70 72 65 64 69 | 63 61 74 65 20 65 6e 61 |is predi|cate ena|
|00001150| 62 6c 65 73 20 74 68 65 | 0a 50 72 6f 6c 6f 67 20 |bles the|.Prolog |
|00001160| 75 73 65 72 20 74 6f 20 | 64 65 66 69 6e 65 20 61 |user to |define a|
|00001170| 20 63 6f 6d 70 6c 65 74 | 65 20 6e 65 77 20 64 65 | complet|e new de|
|00001180| 62 75 67 67 65 72 20 69 | 6e 20 50 72 6f 6c 6f 67 |bugger i|n Prolog|
|00001190| 2e 20 42 65 73 69 64 65 | 73 20 74 68 69 73 20 69 |. Beside|s this i|
|000011a0| 74 0a 65 6e 61 62 6c 65 | 73 20 74 68 65 20 50 72 |t.enable|s the Pr|
|000011b0| 6f 6c 6f 67 20 70 72 6f | 67 72 61 6d 6d 65 72 20 |olog pro|grammer |
|000011c0| 6d 6f 6e 69 74 6f 72 20 | 74 68 65 20 65 78 65 63 |monitor |the exec|
|000011d0| 75 74 69 6f 6e 20 6f 66 | 20 61 20 70 72 6f 67 72 |ution of| a progr|
|000011e0| 61 6d 2e 20 54 68 65 0a | 65 78 61 6d 70 6c 65 20 |am. The.|example |
|000011f0| 62 65 6c 6f 77 20 72 65 | 63 6f 72 64 73 20 61 6c |below re|cords al|
|00001200| 6c 20 67 6f 61 6c 73 20 | 74 72 61 70 70 65 64 20 |l goals |trapped |
|00001210| 62 79 20 74 68 65 20 74 | 72 61 63 65 72 20 69 6e |by the t|racer in|
|00001220| 20 74 68 65 20 64 61 74 | 61 62 61 73 65 2e 0a 0a | the dat|abase...|
|00001230| 5c 62 65 67 69 6e 7b 63 | 6f 64 65 7d 0a 70 72 6f |\begin{c|ode}.pro|
|00001240| 6c 6f 67 5f 74 72 61 63 | 65 5f 69 6e 74 65 72 63 |log_trac|e_interc|
|00001250| 65 70 74 69 6f 6e 28 50 | 6f 72 74 2c 20 46 72 61 |eption(P|ort, Fra|
|00001260| 6d 65 2c 20 5f 50 43 2c | 20 63 6f 6e 74 69 6e 75 |me, _PC,| continu|
|00001270| 65 29 20 3a 2d 0a 20 20 | 20 20 20 20 20 20 70 72 |e) :-. | pr|
|00001280| 6f 6c 6f 67 5f 66 72 61 | 6d 65 5f 61 74 74 72 69 |olog_fra|me_attri|
|00001290| 62 75 74 65 28 46 72 61 | 6d 65 2c 20 67 6f 61 6c |bute(Fra|me, goal|
|000012a0| 2c 20 47 6f 61 6c 29 2c | 20 0a 20 20 20 20 20 20 |, Goal),| . |
|000012b0| 20 20 70 72 6f 6c 6f 67 | 5f 66 72 61 6d 65 5f 61 | prolog|_frame_a|
|000012c0| 74 74 72 69 62 75 74 65 | 28 46 72 61 6d 65 2c 20 |ttribute|(Frame, |
|000012d0| 6c 65 76 65 6c 2c 20 4c | 65 76 65 6c 29 2c 20 0a |level, L|evel), .|
|000012e0| 20 20 20 20 20 20 20 20 | 72 65 63 6f 72 64 7a 28 | |recordz(|
|000012f0| 74 72 61 63 65 2c 20 74 | 72 61 63 65 28 50 6f 72 |trace, t|race(Por|
|00001300| 74 2c 20 4c 65 76 65 6c | 2c 20 47 6f 61 6c 29 29 |t, Level|, Goal))|
|00001310| 2e 0a 5c 65 6e 64 7b 63 | 6f 64 65 7d 0a 0a 54 6f |..\end{c|ode}..To|
|00001320| 20 74 72 61 63 65 20 74 | 68 65 20 65 78 65 63 75 | trace t|he execu|
|00001330| 74 69 6f 6e 20 6f 66 20 | 60 67 6f 27 20 74 68 69 |tion of |`go' thi|
|00001340| 73 20 77 61 79 20 74 68 | 65 20 66 6f 6c 6c 6f 77 |s way th|e follow|
|00001350| 69 6e 67 20 71 75 65 72 | 79 20 73 68 6f 75 6c 64 |ing quer|y should|
|00001360| 20 62 65 0a 67 69 76 65 | 6e 3a 0a 0a 5c 62 65 67 | be.give|n:..\beg|
|00001370| 69 6e 7b 63 6f 64 65 7d | 0a 3f 2d 20 74 72 61 63 |in{code}|.?- trac|
|00001380| 65 2c 20 67 6f 2c 20 6e | 6f 74 72 61 63 65 2e 0a |e, go, n|otrace..|
|00001390| 5c 65 6e 64 7b 63 6f 64 | 65 7d 0a 0a 20 20 20 20 |\end{cod|e}.. |
|000013a0| 5c 70 72 65 64 69 63 61 | 74 65 7b 70 72 6f 6c 6f |\predica|te{prolo|
|000013b0| 67 5f 73 6b 69 70 5f 6c | 65 76 65 6c 7d 7b 32 7d |g_skip_l|evel}{2}|
|000013c0| 7b 2d 4f 6c 64 2c 20 2b | 4e 65 77 7d 0a 55 6e 69 |{-Old, +|New}.Uni|
|000013d0| 66 79 20 5c 61 72 67 7b | 4f 6c 64 7d 20 77 69 74 |fy \arg{|Old} wit|
|000013e0| 68 20 74 68 65 20 6f 6c | 64 20 76 61 6c 75 65 20 |h the ol|d value |
|000013f0| 6f 66 20 60 73 6b 69 70 | 20 6c 65 76 65 6c 27 20 |of `skip| level' |
|00001400| 61 6e 64 20 74 68 61 6e | 20 73 65 74 20 74 68 69 |and than| set thi|
|00001410| 73 0a 6c 65 76 65 6c 20 | 61 63 63 6f 72 64 69 6e |s.level |accordin|
|00001420| 67 20 74 6f 20 5c 61 72 | 67 7b 4e 65 77 7d 2e 20 |g to \ar|g{New}. |
|00001430| 20 4e 65 77 20 69 73 20 | 61 6e 20 69 6e 74 65 67 | New is |an integ|
|00001440| 65 72 2c 20 6f 72 20 74 | 68 65 20 73 70 65 63 69 |er, or t|he speci|
|00001450| 61 6c 20 61 74 6f 6d 0a | 5c 63 6f 6e 73 74 7b 76 |al atom.|\const{v|
|00001460| 65 72 79 5f 64 65 65 70 | 7d 20 28 6d 65 61 6e 69 |ery_deep|} (meani|
|00001470| 6e 67 20 64 6f 6e 27 74 | 20 73 6b 69 70 29 2e 20 |ng don't| skip). |
|00001480| 20 54 68 65 20 60 73 6b | 69 70 20 6c 65 76 65 6c | The `sk|ip level|
|00001490| 27 20 69 73 20 61 20 67 | 6c 6f 62 61 6c 0a 76 61 |' is a g|lobal.va|
|000014a0| 72 69 61 62 6c 65 20 6f | 66 20 74 68 65 20 50 72 |riable o|f the Pr|
|000014b0| 6f 6c 6f 67 20 73 79 73 | 74 65 6d 20 74 68 61 74 |olog sys|tem that|
|000014c0| 20 64 69 73 61 62 6c 65 | 73 20 74 68 65 20 64 65 | disable|s the de|
|000014d0| 62 75 67 67 65 72 20 6f | 6e 20 61 6c 6c 0a 72 65 |bugger o|n all.re|
|000014e0| 63 75 72 73 69 6f 6e 20 | 6c 65 76 65 6c 73 20 64 |cursion |levels d|
|000014f0| 65 65 70 65 72 20 74 68 | 61 6e 20 74 68 65 20 6c |eeper th|an the l|
|00001500| 65 76 65 6c 20 6f 66 20 | 74 68 65 20 76 61 72 69 |evel of |the vari|
|00001510| 61 62 6c 65 2e 20 20 55 | 73 65 64 20 74 6f 0a 69 |able. U|sed to.i|
|00001520| 6d 70 6c 65 6d 65 6e 74 | 20 74 68 65 20 74 72 61 |mplement| the tra|
|00001530| 63 65 20 6f 70 74 69 6f | 6e 73 20 60 73 6b 69 70 |ce optio|ns `skip|
|00001540| 27 20 28 73 65 74 73 20 | 73 6b 69 70 20 6c 65 76 |' (sets |skip lev|
|00001550| 65 6c 20 74 6f 20 74 68 | 65 20 6c 65 76 65 6c 20 |el to th|e level |
|00001560| 6f 66 20 74 68 65 0a 66 | 72 61 6d 65 29 20 61 6e |of the.f|rame) an|
|00001570| 64 20 60 75 70 27 20 28 | 73 65 74 73 20 73 6b 69 |d `up' (|sets ski|
|00001580| 70 20 6c 65 76 65 6c 20 | 74 6f 20 74 68 65 20 6c |p level |to the l|
|00001590| 65 76 65 6c 20 6f 66 20 | 74 68 65 20 70 61 72 65 |evel of |the pare|
|000015a0| 6e 74 20 66 72 61 6d 65 | 20 28 69 2e 65 2e 5c 0a |nt frame| (i.e.\.|
|000015b0| 74 68 65 20 6c 65 76 65 | 6c 20 6f 66 20 74 68 69 |the leve|l of thi|
|000015c0| 73 20 66 72 61 6d 65 20 | 6d 69 6e 75 73 20 31 29 |s frame |minus 1)|
|000015d0| 2e 0a 5c 65 6e 64 7b 64 | 65 73 63 72 69 70 74 69 |..\end{d|escripti|
|000015e0| 6f 6e 7d 0a 0a 5c 73 65 | 63 74 69 6f 6e 7b 45 78 |on}..\se|ction{Ex|
|000015f0| 63 65 70 74 69 6f 6e 20 | 48 61 6e 64 6c 69 6e 67 |ception |Handling|
|00001600| 7d 0a 0a 41 20 73 74 61 | 72 74 20 68 61 73 20 62 |}..A sta|rt has b|
|00001610| 65 65 6e 20 6d 61 64 65 | 20 74 6f 20 6d 61 6b 65 |een made| to make|
|00001620| 20 65 78 63 65 70 74 69 | 6f 6e 20 68 61 6e 64 6c | excepti|on handl|
|00001630| 69 6e 67 20 61 76 61 69 | 6c 61 62 6c 65 20 74 6f |ing avai|lable to|
|00001640| 20 74 68 65 0a 50 72 6f | 6c 6f 67 20 75 73 65 72 | the.Pro|log user|
|00001650| 2e 20 4f 6e 20 65 78 63 | 65 70 74 69 6f 6e 73 20 |. On exc|eptions |
|00001660| 61 20 64 79 6e 61 6d 69 | 63 20 61 6e 64 20 6d 75 |a dynami|c and mu|
|00001670| 6c 74 69 66 69 6c 65 20 | 64 65 66 69 6e 65 64 20 |ltifile |defined |
|00001680| 70 72 65 64 69 63 61 74 | 65 0a 65 78 63 65 70 74 |predicat|e.except|
|00001690| 69 6f 6e 2f 33 20 69 73 | 20 63 61 6c 6c 65 64 2e |ion/3 is| called.|
|000016a0| 20 49 66 20 74 68 69 73 | 20 75 73 65 72 20 64 65 | If this| user de|
|000016b0| 66 69 6e 65 64 20 70 72 | 65 64 69 63 61 74 65 20 |fined pr|edicate |
|000016c0| 73 75 63 63 65 65 64 73 | 20 50 72 6f 6c 6f 67 0a |succeeds| Prolog.|
|000016d0| 61 73 73 75 6d 65 73 20 | 74 68 65 20 65 78 63 65 |assumes |the exce|
|000016e0| 70 74 69 6f 6e 20 68 61 | 73 20 62 65 65 6e 20 74 |ption ha|s been t|
|000016f0| 61 6b 65 6e 20 63 61 72 | 65 20 6f 66 2e 20 4f 74 |aken car|e of. Ot|
|00001700| 68 65 72 77 69 73 65 20 | 74 68 65 20 73 79 73 74 |herwise |the syst|
|00001710| 65 6d 0a 64 65 66 61 75 | 6c 74 20 65 78 63 65 70 |em.defau|lt excep|
|00001720| 74 69 6f 6e 20 68 61 6e | 64 6c 65 72 20 69 73 20 |tion han|dler is |
|00001730| 63 61 6c 6c 65 64 2e 0a | 0a 5c 62 65 67 69 6e 7b |called..|.\begin{|
|00001740| 64 65 73 63 72 69 70 74 | 69 6f 6e 7d 0a 20 20 20 |descript|ion}. |
|00001750| 20 5c 70 72 65 64 69 63 | 61 74 65 7b 65 78 63 65 | \predic|ate{exce|
|00001760| 70 74 69 6f 6e 7d 7b 33 | 7d 7b 2b 45 78 63 65 70 |ption}{3|}{+Excep|
|00001770| 74 69 6f 6e 2c 20 2b 43 | 6f 6e 74 65 78 74 2c 20 |tion, +C|ontext, |
|00001780| 2d 41 63 74 69 6f 6e 7d | 0a 44 79 6e 61 6d 69 63 |-Action}|.Dynamic|
|00001790| 20 70 72 65 64 69 63 61 | 74 65 2c 20 6e 6f 72 6d | predica|te, norm|
|000017a0| 61 6c 6c 79 20 6e 6f 74 | 20 64 65 66 69 6e 65 64 |ally not| defined|
|000017b0| 2e 20 20 43 61 6c 6c 65 | 64 20 62 79 20 74 68 65 |. Calle|d by the|
|000017c0| 20 50 72 6f 6c 6f 67 20 | 73 79 73 74 65 6d 20 6f | Prolog |system o|
|000017d0| 6e 0a 72 75 6e 2d 74 69 | 6d 65 20 65 78 63 65 70 |n.run-ti|me excep|
|000017e0| 74 69 6f 6e 73 2e 20 20 | 43 75 72 72 65 6e 74 6c |tions. |Currentl|
|000017f0| 79 20 65 78 63 65 70 74 | 69 6f 6e 2f 33 20 69 73 |y except|ion/3 is|
|00001800| 20 6f 6e 6c 79 20 75 73 | 65 64 20 66 6f 72 20 74 | only us|ed for t|
|00001810| 72 61 70 70 69 6e 67 0a | 75 6e 64 65 66 69 6e 65 |rapping.|undefine|
|00001820| 64 20 70 72 65 64 69 63 | 61 74 65 73 2e 20 20 46 |d predic|ates. F|
|00001830| 75 74 75 72 65 20 76 65 | 72 73 69 6f 6e 73 20 6d |uture ve|rsions m|
|00001840| 69 67 68 74 20 68 61 6e | 64 6c 65 20 73 69 67 6e |ight han|dle sign|
|00001850| 61 6c 20 68 61 6e 64 6c | 69 6e 67 2c 20 0a 66 6c |al handl|ing, .fl|
|00001860| 6f 61 74 69 6e 67 20 65 | 78 63 65 70 74 69 6f 6e |oating e|xception|
|00001870| 73 20 61 6e 64 20 6f 74 | 68 65 72 20 72 75 6e 74 |s and ot|her runt|
|00001880| 69 6d 65 20 65 72 72 6f | 72 73 20 76 69 61 20 74 |ime erro|rs via t|
|00001890| 68 69 73 20 6d 65 63 68 | 61 6e 69 73 6d 2e 20 54 |his mech|anism. T|
|000018a0| 68 65 0a 76 61 6c 75 65 | 73 20 66 6f 72 20 5c 61 |he.value|s for \a|
|000018b0| 72 67 7b 45 78 63 65 70 | 74 69 6f 6e 7d 20 61 72 |rg{Excep|tion} ar|
|000018c0| 65 20 64 65 73 63 72 69 | 62 65 64 20 62 65 6c 6f |e descri|bed belo|
|000018d0| 77 2e 0a 0a 5c 62 65 67 | 69 6e 7b 64 65 73 63 72 |w...\beg|in{descr|
|000018e0| 69 70 74 69 6f 6e 7d 0a | 20 20 20 20 5c 74 65 72 |iption}.| \ter|
|000018f0| 6d 69 74 65 6d 7b 75 6e | 64 65 66 69 6e 65 64 5f |mitem{un|defined_|
|00001900| 70 72 65 64 69 63 61 74 | 65 7d 7b 7d 0a 49 66 20 |predicat|e}{}.If |
|00001910| 5c 61 72 67 7b 45 78 63 | 65 70 74 69 6f 6e 7d 20 |\arg{Exc|eption} |
|00001920| 69 73 20 5c 63 6f 6e 73 | 74 7b 75 6e 64 65 66 69 |is \cons|t{undefi|
|00001930| 6e 65 64 5f 70 72 65 64 | 69 63 61 74 65 7d 20 5c |ned_pred|icate} \|
|00001940| 61 72 67 7b 43 6f 6e 74 | 65 78 74 7d 20 69 73 0a |arg{Cont|ext} is.|
|00001950| 69 6e 73 74 61 6e 74 69 | 61 74 65 64 20 74 6f 20 |instanti|ated to |
|00001960| 61 20 74 65 72 6d 20 5c | 61 72 67 7b 4e 61 6d 65 |a term \|arg{Name|
|00001970| 7d 2f 5c 61 72 67 7b 41 | 72 69 74 79 7d 2e 20 20 |}/\arg{A|rity}. |
|00001980| 5c 61 72 67 7b 4e 61 6d | 65 7d 20 72 65 66 65 72 |\arg{Nam|e} refer|
|00001990| 73 20 74 6f 20 74 68 65 | 0a 6e 61 6d 65 20 61 6e |s to the|.name an|
|000019a0| 64 20 5c 61 72 67 7b 41 | 72 69 74 79 7d 20 74 6f |d \arg{A|rity} to|
|000019b0| 20 74 68 65 20 61 72 69 | 74 79 20 6f 66 20 74 68 | the ari|ty of th|
|000019c0| 65 20 75 6e 64 65 66 69 | 6e 65 64 20 70 72 65 64 |e undefi|ned pred|
|000019d0| 69 63 61 74 65 2e 20 20 | 49 66 20 74 68 65 0a 64 |icate. |If the.d|
|000019e0| 65 66 69 6e 69 74 69 6f | 6e 20 6d 6f 64 75 6c 65 |efinitio|n module|
|000019f0| 20 6f 66 20 74 68 65 20 | 70 72 65 64 69 63 61 74 | of the |predicat|
|00001a00| 65 20 69 73 20 6e 6f 74 | 20 5c 61 72 67 7b 75 73 |e is not| \arg{us|
|00001a10| 65 72 7d 2c 20 5c 61 72 | 67 7b 43 6f 6e 74 65 78 |er}, \ar|g{Contex|
|00001a20| 74 7d 20 77 69 6c 6c 0a | 62 65 20 6f 66 20 74 68 |t} will.|be of th|
|00001a30| 65 20 66 6f 72 6d 20 5c | 6d 62 6f 78 7b 5c 74 74 |e form \|mbox{\tt|
|00001a40| 20 3c 4d 6f 64 75 6c 65 | 3e 3a 3c 4e 61 6d 65 3e | <Module|>:<Name>|
|00001a50| 2f 3c 41 72 69 74 79 3e | 7d 2e 20 20 49 66 20 74 |/<Arity>|}. If t|
|00001a60| 68 65 20 70 72 65 64 69 | 63 61 74 65 20 66 61 69 |he predi|cate fai|
|00001a70| 6c 73 0a 50 72 6f 6c 6f | 67 20 77 69 6c 6c 20 70 |ls.Prolo|g will p|
|00001a80| 72 69 6e 74 20 74 68 65 | 20 64 65 66 61 75 6c 74 |rint the| default|
|00001a90| 20 65 72 72 6f 72 20 77 | 61 72 6e 69 6e 67 20 61 | error w|arning a|
|00001aa0| 6e 64 20 73 74 61 72 74 | 20 74 68 65 20 74 72 61 |nd start| the tra|
|00001ab0| 63 65 72 2e 20 20 49 66 | 0a 74 68 65 20 70 72 65 |cer. If|.the pre|
|00001ac0| 64 69 63 61 74 65 20 73 | 75 63 63 65 65 64 73 20 |dicate s|ucceeds |
|00001ad0| 69 74 20 73 68 6f 75 6c | 64 20 69 6e 73 74 61 6e |it shoul|d instan|
|00001ae0| 74 69 61 74 65 20 74 68 | 65 20 6c 61 73 74 20 61 |tiate th|e last a|
|00001af0| 72 67 75 6d 65 6e 74 20 | 65 69 74 68 65 72 20 74 |rgument |either t|
|00001b00| 6f 0a 74 68 65 20 61 74 | 6f 6d 20 5c 63 6f 6e 73 |o.the at|om \cons|
|00001b10| 74 7b 66 61 69 6c 7d 20 | 74 6f 20 74 65 6c 6c 20 |t{fail} |to tell |
|00001b20| 50 72 6f 6c 6f 67 20 74 | 6f 20 66 61 69 6c 20 74 |Prolog t|o fail t|
|00001b30| 68 65 20 70 72 65 64 69 | 63 61 74 65 20 6f 72 20 |he predi|cate or |
|00001b40| 74 68 65 20 61 74 6f 6d | 0a 5c 63 6f 6e 73 74 7b |the atom|.\const{|
|00001b50| 72 65 74 72 79 7d 20 74 | 6f 20 74 65 6c 6c 20 50 |retry} t|o tell P|
|00001b60| 72 6f 6c 6f 67 20 74 6f | 20 72 65 74 72 79 20 74 |rolog to| retry t|
|00001b70| 68 65 20 70 72 65 64 69 | 63 61 74 65 2e 20 20 54 |he predi|cate. T|
|00001b80| 68 69 73 20 6f 6e 6c 79 | 20 6d 61 6b 65 73 0a 73 |his only| makes.s|
|00001b90| 65 6e 73 65 20 69 66 20 | 74 68 65 20 65 78 63 65 |ense if |the exce|
|00001ba0| 70 74 69 6f 6e 20 68 61 | 6e 64 6c 65 72 20 68 61 |ption ha|ndler ha|
|00001bb0| 73 20 64 65 66 69 6e 65 | 64 20 74 68 65 20 70 72 |s define|d the pr|
|00001bc0| 65 64 69 63 61 74 65 2e | 20 20 4f 74 68 65 72 77 |edicate.| Otherw|
|00001bd0| 69 73 65 20 69 74 0a 77 | 69 6c 6c 20 6c 65 61 64 |ise it.w|ill lead|
|00001be0| 20 74 6f 20 61 20 6c 6f | 6f 70 2e 0a 20 20 20 20 | to a lo|op.. |
|00001bf0| 5c 74 65 72 6d 69 74 65 | 6d 7b 77 61 72 6e 69 6e |\termite|m{warnin|
|00001c00| 67 7d 7b 7d 0a 49 66 20 | 70 72 6f 6c 6f 67 20 77 |g}{}.If |prolog w|
|00001c10| 61 6e 74 73 20 74 6f 20 | 67 69 76 65 20 61 20 77 |ants to |give a w|
|00001c20| 61 72 6e 69 6e 67 20 77 | 68 69 6c 65 20 72 65 61 |arning w|hile rea|
|00001c30| 64 69 6e 67 20 61 20 66 | 69 6c 65 2c 20 69 74 20 |ding a f|ile, it |
|00001c40| 77 69 6c 6c 20 66 69 72 | 73 74 0a 72 61 69 73 65 |will fir|st.raise|
|00001c50| 20 74 68 65 20 65 78 63 | 65 70 74 69 6f 6e 20 5c | the exc|eption \|
|00001c60| 61 72 67 7b 77 61 72 6e | 69 6e 67 7d 2e 20 20 54 |arg{warn|ing}. T|
|00001c70| 68 65 20 63 6f 6e 74 65 | 78 74 20 61 72 67 75 6d |he conte|xt argum|
|00001c80| 65 6e 74 20 69 73 20 61 | 20 74 65 72 6d 20 6f 66 |ent is a| term of|
|00001c90| 0a 74 68 65 20 66 6f 72 | 6d 20 5c 65 78 61 6d 7b |.the for|m \exam{|
|00001ca0| 77 61 72 6e 69 6e 67 28 | 3c 50 61 74 68 3e 2c 20 |warning(|<Path>, |
|00001cb0| 3c 4c 69 6e 65 4e 6f 3e | 2c 20 3c 4d 65 73 73 61 |<LineNo>|, <Messa|
|00001cc0| 67 65 3e 29 7d 2c 20 77 | 68 65 72 65 20 5c 61 72 |ge>)}, w|here \ar|
|00001cd0| 67 7b 50 61 74 68 7d 20 | 69 73 20 74 68 65 0a 61 |g{Path} |is the.a|
|00001ce0| 62 73 6f 6c 75 74 65 20 | 66 69 6c 65 6e 61 6d 65 |bsolute |filename|
|00001cf0| 20 6f 66 20 74 68 65 20 | 66 69 6c 65 20 70 72 6f | of the |file pro|
|00001d00| 6c 6f 67 20 69 73 20 72 | 65 61 64 69 6e 67 3b 20 |log is r|eading; |
|00001d10| 5c 61 72 67 7b 4c 69 6e | 65 4e 6f 7d 20 69 73 20 |\arg{Lin|eNo} is |
|00001d20| 61 6e 0a 65 73 74 69 6d | 61 74 65 20 6f 66 20 74 |an.estim|ate of t|
|00001d30| 68 65 20 6c 69 6e 65 20 | 6e 75 6d 62 65 72 20 77 |he line |number w|
|00001d40| 68 65 72 65 20 74 68 65 | 20 65 72 72 6f 72 20 6f |here the| error o|
|00001d50| 63 63 75 72 72 65 64 20 | 61 6e 64 20 5c 61 72 67 |ccurred |and \arg|
|00001d60| 7b 4d 65 73 73 61 67 65 | 7d 0a 69 73 20 61 20 50 |{Message|}.is a P|
|00001d70| 72 6f 6c 6f 67 20 73 74 | 72 69 6e 67 20 69 6e 64 |rolog st|ring ind|
|00001d80| 69 63 61 74 69 6e 67 20 | 74 68 65 20 6d 65 73 73 |icating |the mess|
|00001d90| 61 67 65 2e 20 20 54 68 | 65 20 5c 61 72 67 7b 41 |age. Th|e \arg{A|
|00001da0| 63 74 69 6f 6e 7d 20 61 | 72 67 75 6d 65 6e 74 20 |ction} a|rgument |
|00001db0| 69 73 0a 69 67 6e 6f 72 | 65 64 2e 20 20 54 68 65 |is.ignor|ed. The|
|00001dc0| 20 65 72 72 6f 72 20 69 | 73 20 73 75 70 70 6f 73 | error i|s suppos|
|00001dd0| 65 64 20 74 6f 20 62 65 | 20 70 72 65 73 65 6e 74 |ed to be| present|
|00001de0| 65 64 20 74 6f 20 74 68 | 65 20 75 73 65 72 20 69 |ed to th|e user i|
|00001df0| 66 20 74 68 65 0a 65 78 | 63 65 70 74 69 6f 6e 20 |f the.ex|ception |
|00001e00| 68 61 6e 64 6c 65 72 20 | 73 75 63 63 65 65 64 73 |handler |succeeds|
|00001e10| 2e 20 20 4f 74 68 65 72 | 77 69 73 65 20 74 68 65 |. Other|wise the|
|00001e20| 20 73 74 61 6e 64 61 72 | 64 20 50 72 6f 6c 6f 67 | standar|d Prolog|
|00001e30| 20 77 61 72 6e 69 6e 67 | 20 6d 65 73 73 61 67 65 | warning| message|
|00001e40| 0a 69 73 20 70 72 69 6e | 74 65 64 2e 0a 0a 54 68 |.is prin|ted...Th|
|00001e50| 69 73 20 65 78 63 65 70 | 74 69 6f 6e 20 69 73 20 |is excep|tion is |
|00001e60| 75 73 65 64 20 62 79 20 | 74 68 65 20 5c 66 69 6c |used by |the \fil|
|00001e70| 65 7b 6c 69 62 72 61 72 | 79 28 65 6d 61 63 73 5f |e{librar|y(emacs_|
|00001e80| 69 6e 74 65 72 66 61 63 | 65 29 7d 2c 20 74 68 61 |interfac|e)}, tha|
|00001e90| 74 0a 69 6e 74 65 67 72 | 61 74 65 73 20 65 72 72 |t.integr|ates err|
|00001ea0| 6f 72 20 68 61 6e 64 6c | 69 6e 67 20 77 69 74 68 |or handl|ing with|
|00001eb0| 20 5c 70 72 6f 67 72 61 | 6d 7b 47 4e 55 7e 45 6d | \progra|m{GNU~Em|
|00001ec0| 61 63 73 7d 2e 0a 5c 65 | 6e 64 7b 64 65 73 63 72 |acs}..\e|nd{descr|
|00001ed0| 69 70 74 69 6f 6e 7d 0a | 5c 65 6e 64 7b 64 65 73 |iption}.|\end{des|
|00001ee0| 63 72 69 70 74 69 6f 6e | 7d 0a 0a 5c 73 65 63 74 |cription|}..\sect|
|00001ef0| 69 6f 6e 7b 52 65 61 64 | 6c 69 6e 65 20 49 6e 74 |ion{Read|line Int|
|00001f00| 65 72 61 63 74 69 6f 6e | 7d 0a 0a 54 68 65 20 66 |eraction|}..The f|
|00001f10| 6f 6c 6c 6f 77 69 6e 67 | 20 70 72 65 64 69 63 61 |ollowing| predica|
|00001f20| 74 65 73 20 61 72 65 20 | 61 76 61 69 6c 61 62 6c |tes are |availabl|
|00001f30| 65 20 69 66 20 5c 65 78 | 61 6d 7b 66 65 61 74 75 |e if \ex|am{featu|
|00001f40| 72 65 28 72 65 61 64 6c | 69 6e 65 2c 20 74 72 75 |re(readl|ine, tru|
|00001f50| 65 29 7d 0a 73 75 63 63 | 65 65 64 73 2e 20 20 54 |e)}.succ|eeds. T|
|00001f60| 68 65 79 20 61 6c 6c 6f | 77 20 66 6f 72 20 64 69 |hey allo|w for di|
|00001f70| 72 65 63 74 20 69 6e 74 | 65 72 61 63 74 69 6f 6e |rect int|eraction|
|00001f80| 20 77 69 74 68 20 74 68 | 65 20 47 4e 55 20 72 65 | with th|e GNU re|
|00001f90| 61 64 6c 69 6e 65 20 6c | 69 62 72 61 72 79 2e 0a |adline l|ibrary..|
|00001fa0| 53 65 65 20 61 6c 73 6f | 20 5c 6d 61 6e 72 65 66 |See also| \manref|
|00001fb0| 7b 72 65 61 64 6c 69 6e | 65 7d 7b 33 7d 0a 0a 5c |{readlin|e}{3}..\|
|00001fc0| 62 65 67 69 6e 7b 64 65 | 73 63 72 69 70 74 69 6f |begin{de|scriptio|
|00001fd0| 6e 7d 0a 20 20 20 20 5c | 70 72 65 64 69 63 61 74 |n}. \|predicat|
|00001fe0| 65 7b 72 6c 5f 72 65 61 | 64 5f 69 6e 69 74 5f 66 |e{rl_rea|d_init_f|
|00001ff0| 69 6c 65 7d 7b 31 7d 7b | 2b 46 69 6c 65 7d 0a 52 |ile}{1}{|+File}.R|
|00002000| 65 61 64 20 61 20 72 65 | 61 64 6c 69 6e 65 20 69 |ead a re|adline i|
|00002010| 6e 69 74 69 61 6c 69 73 | 61 74 69 6f 6e 20 66 69 |nitialis|ation fi|
|00002020| 6c 65 2e 20 20 52 65 61 | 64 6c 69 6e 65 20 62 79 |le. Rea|dline by|
|00002030| 20 64 65 66 61 75 6c 74 | 20 72 65 61 64 73 0a 5c | default| reads.\|
|00002040| 66 69 6c 65 7b 7e 2f 2e | 69 6e 70 75 74 72 63 7d |file{~/.|inputrc}|
|00002050| 2e 20 20 54 68 69 73 20 | 70 72 65 64 69 63 61 74 |. This |predicat|
|00002060| 65 20 6d 61 79 20 62 65 | 20 75 73 65 64 20 74 6f |e may be| used to|
|00002070| 20 72 65 61 64 20 61 6c | 74 65 72 6e 61 74 69 76 | read al|ternativ|
|00002080| 65 0a 72 65 61 64 6c 69 | 6e 65 20 69 6e 69 74 69 |e.readli|ne initi|
|00002090| 61 6c 69 73 61 74 69 6f | 6e 20 66 69 6c 65 73 2e |alisatio|n files.|
|000020a0| 0a 20 20 20 20 5c 70 72 | 65 64 69 63 61 74 65 7b |. \pr|edicate{|
|000020b0| 72 6c 5f 61 64 64 5f 68 | 69 73 74 6f 72 79 7d 7b |rl_add_h|istory}{|
|000020c0| 31 7d 7b 2b 4c 69 6e 65 | 7d 0a 41 64 64 20 61 20 |1}{+Line|}.Add a |
|000020d0| 6c 69 6e 65 20 74 6f 20 | 74 68 65 20 43 6f 6e 74 |line to |the Cont|
|000020e0| 72 6f 6c 2d 50 2f 43 6f | 6e 74 72 6f 6c 2d 4e 20 |rol-P/Co|ntrol-N |
|000020f0| 68 69 73 74 6f 72 79 20 | 73 79 73 74 65 6d 20 6f |history |system o|
|00002100| 66 20 74 68 65 20 72 65 | 61 64 6c 69 6e 65 20 6c |f the re|adline l|
|00002110| 69 62 72 61 72 79 2e 0a | 5c 65 6e 64 7b 64 65 73 |ibrary..|\end{des|
|00002120| 63 72 69 70 74 69 6f 6e | 7d 0a |cription|}. |
+--------+-------------------------+-------------------------+--------+--------+